using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SkillObject_SwordPierce : SkillObject_Sword
{

    private int pierceCount;

    public override void SetupSword(Skill_SwordThrow skill_SwordThrow, Vector2 initDirection)
    {
        base.SetupSword(skill_SwordThrow, initDirection);
        pierceCount = skill_SwordThrow.pierceCount;
    }

    protected override void OnTriggerEnter2D(Collider2D collision)
    {
        bool groundHit = collision.gameObject.layer == LayerMask.NameToLayer("Ground");
        if (pierceCount <= 0 || groundHit)
        {
            DamageEnemiesInRedius(transform, 0.3f);
            StopSword(collision);
            return;
        }
        pierceCount--;
        DamageEnemiesInRedius(transform, 0.3f); 
    }
}
